IF EXISTS (SELECT *
           FROM INFORMATION_SCHEMA.ROUTINES
           WHERE ROUTINE_NAME='pProductType_Delete'
           AND ROUTINE_SCHEMA='dbo'
           AND ROUTINE_TYPE='PROCEDURE'
          )
          DROP PROCEDURE dbo.pProductType_Delete
GO

CREATE PROC dbo.pProductType_Delete
	@id  AS INT
AS

	IF NOT EXISTS (SELECT '' FROM Product WHERE ProductTypeId = @id)
	 BEGIN
		UPDATE ProductType
		SET IsDeleted = 1
		WHERE Id = @id
		RETURN 1;
	END
	ELSE
	BEGIN
		RETURN 0;
	END